Dark Horse programmer-abstract class and interface, dark horse programmer Abstract
I recently studied the Java SE video tutorial by Miss Bi Xiangdong. This is the background.
This article describes the simple concepts of abstract classes and interfaces.Abstract class
Keywo
parent class functionsSubclass overrides the parent class function, must ensure that the child class permission is greater than or equal to the parent class permission, otherwise the compilation fails;Static can only be overridden by static.3. Final keyword FeaturesWhen an inner class is defined at a local location, it can only access the locally final decorated local variable and cannot access the externally final decorated variable.4, the subclass of the
Ma Tau and text is a whole effect, but the process is relatively cumbersome. Therefore, the horse's head and text to write separate tutorials. Horse head part of the focus is hand-painted, text part of the stereo effect can be. This tutorial only describes the MA tau part of the production.
Final effect
Add text after the effect. Text Tutorial Follo
-abstract methods. There is no implementation method in the interface.5. The variable defined in the interface is the public static final type by default, and must be given its initial value, so the implementation class cannot be redefined or changed.6. Variables in abstract classes are friendly by default, whose values can be redefined in subclasses or re-assigned.7. The methods in the interface are public
method of the parent class. public void Eat () {System.out.println ("Dog eats Bones");}} Defines the cat that will jump high class Jumpcat extends cat implements Jump{public Jumpcat () {}public jumpcat (String name,int age) {Super ( Name,age);} public void jumps () {System.out.println ("High jump cat will high Jump");}} Defines the dog that will jump high to achieve the height of class Jumpdog extends dog implements Jump{public Jumpdog ({}public Jumpdog (String name,int age) {super (name,age);}
abstract, cannot have the implementation of curly braces.Interfaces and abstract classes function Similarly, interfaces cannot be instantiated, and interfaces can be thought of as a special abstract class (all abstract methods).The polymorphic usage of an interface is similar to an
do not know the specific content. These are not accurateThe function of the object, which needs to be clarified, but cannot define the subject. Represented by an abstract method.2, abstract analogy general class more than an abstract function. is to define an abstract method in a class.3,
-abstract methods, this class is still unable to create objects, this is very rare, usually to not want to create objects such as the abstract decorationAbstract class cx{ void Aa () { System.out.println ("I am the Normal method"); } void BB () { System.out.println ("I am also common method");} } 3. There can be
** @description Abstract class Learning test class* @history*/Abstract class abstract{//define Abstraction classesPublic final static String INFO = "Helloeclipse"; Defining Global variables/constantsAbstract public void print (); Defining abstract methodsAbstract classes cannot be instantiated directly, and subclasses
1, the abstract class can have a construction method, mainly when the subclass is instantiated, initialization. 2, there can be no abstract method in an abstract classThe point is not to let outsiders create objects. 3, the coexistence of abstract classes and keywords Private Abstratc method (); To rewrite, but does n
1, the abstract class can have a construction method, mainly when the subclass is instantiated, initialization. 2, there can be no abstract method in an abstract classThe point is not to let outsiders create objects. 3, the coexistence of abstract classes and keywords Private Abstratc method (); To rewrite, but does n
Abstract classes are often used to characterize the abstract concepts we derive in the analysis and design of the problem domain, as an abstraction of a series of concrete concepts that look different, but are essentially the same, and we cannot instantiate them (not get a concrete one) so they are called abstractions. For example: We want to describe "fruit", it is an abstraction, it has quality, volume an
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.